package icom.acm.dwr;

import icom.acm.bean.T_USER;
import icom.acm.util.RedisUtil;
import icom.acm.util.StaticData;
import icom.acm.util.json.JSONMsg;
import icom.acm.util.redis.RedisDB;

import javax.servlet.http.HttpSession;

import org.directwebremoting.ScriptSession;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;

import redis.clients.jedis.Jedis;

public class LoadPageDWR {
	public String Load(){
		System.out.println("DWR: mircblogLoad");
		JSONMsg jmsg = null;
		WebContext wctx = WebContextFactory.get();
		HttpSession session = wctx.getSession();
		ScriptSession scriptSession = wctx.getScriptSession();
		
		T_USER user = (T_USER)session.getAttribute("user");
		if (user==null){
			return "";
		}
		StaticData.SESSIONID_SCRIPTSESSION_MAP.put(session.getId(), scriptSession);
		Jedis jedis = RedisDB.newInstance().get_Jedis();		
		String key = RedisUtil.KEY_MESSAGE2USER + user.getU_ID();
		jedis.del(key);
		return "mircblogLoad";
	}
}
